package com.assignwork.vo;

import com.assignwork.entity.ShipDynamic;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
public class ShipDynamicVO {

    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
    @JsonFormat(pattern = DateUtil.PATTERN_DATE)
    private LocalDate planDate;
    private String planner;
    private Object sourceData;
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    private LocalDateTime realTime;
    private String planBerth;
    private String beginBerth;
    private String requirement;
    private String lastBerth;
    private String afd;
    private String aad;
    private String reason;
    @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    private LocalDateTime modifiedTime;
    private String modifiedUser;
    private String begCable;
    private String endCable;

    private GroupDayStatPlanVO data;

    public GroupDayStatPlanVO getData() {
        if (sourceData != null) {
            return Func.readJson(sourceData.toString(), GroupDayStatPlanVO.class);
        }
        return data;
    }
}
